home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / PopupCDEF-10b4 / Source / PopupLib.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-01  |  5.0 KB  |  134 lines  |  [TEXT/KAHL]

  1. /* See the file Distribution for distribution terms.
  2.     (c) Copyright 1994 Ari Halberstadt */
  3.     
  4. #pragma once
  5.  
  6. #include <Controls.h>
  7. #include <QDOffscreen.h>
  8. #include "PopupCDEF.h"
  9.  
  10. /* M68K JMP instruction (for MDEF and CDEF glue) */
  11. #define ASM_M68K_JMP            (0x4EF9)
  12.  
  13. /* for saving/restoring a port's text state */
  14. typedef struct {
  15.     short    font;
  16.     Style    face;
  17.     short    mode;
  18.     short    size;
  19. } TextState;
  20.  
  21. /* for saving/restoring a port's color state */
  22. typedef struct {
  23.     RGBColor fore;
  24.     RGBColor back;
  25. } ColorState;
  26.  
  27. /* Drawing environment data which must be remembered before any drawing
  28.     of the popup menu is begun and restored after all drawing has finished. */
  29. typedef struct {
  30.     GrafPtr        port;            /* graf port on entry to popup cdef */
  31.     PenState        pen;            /* saved pen state for popup's port */
  32.     TextState    text;            /* saved text state for popup's port */
  33.     ColorState    color;        /* saved color state for popup's port */
  34.     RgnHandle    clip;            /* saved clip region for popup's port */
  35.     short            sysfont;        /* saved system font */
  36.     short            syssize;        /* saved system font size */
  37. } PopupEnvType;
  38.  
  39. /* rectangles defining the various areas of a popup menu */
  40. typedef struct {
  41.     Rect maxbounds;            /* maximum bounding rectangle of popup */
  42.     Rect bounds;                /* rectangle around all of popup */
  43.     Rect hilite;                /* hilited when a selection is being made */
  44.     Rect title;                    /* contains the popup's title */
  45.     Rect selection;            /* contains the currently selected item */
  46.     Rect arrow;                    /* contains the down arrow */
  47. } PopupRectanglesType;
  48.  
  49. /* structure containing all the data needed by the popup menu */
  50. typedef struct {
  51.  
  52.     /* these first two fields will never be changed, other fields may change */
  53.     PopupPrivateType private;    /* for compatability with Apple's CDEF */
  54.     short                version;        /* version of the code that created this popup menu */
  55.  
  56.     /* fields specified on creation of the popup menu (maxbounds is in
  57.         rectangles field) */
  58.     GrafPtr            port;            /* port to draw into */
  59.     MenuHandle        menu;            /* handle to menu */
  60.     
  61.     /* for patching the menu definition function */
  62.     Handle            menuProc;    /* glue to call our own MDEF */
  63.     
  64.     /* information needed when drawing */
  65.     struct {
  66.         GDHandle        gdevice;        /* graphics device to draw into */
  67.         short            gdepth;        /* pixel depth of graphics device */
  68.         GWorldPtr    gworld;        /* offscreen graphics world */
  69.         RgnHandle    utilRgn;        /* utility region */
  70.         PopupEnvType save;         /* saved drawing environment */
  71.     } draw;
  72.     
  73.     /* internal state information */
  74.     PopupRectanglesType r;        /* rectangles enclosing areas of the popup menu */
  75.     struct {
  76.         short            current;        /* currently selected item number */
  77.         Boolean        drawset:1;    /* true after drawing environment has been setup */
  78.         Boolean        gotmenu:1;    /* used by CDEF; true means CDEF created menu */
  79.         Boolean        changed:1;    /* true if popup's image changed and needs redrawing */
  80.     } state;
  81.     
  82.     /* User settable attributes of the menu. External functions
  83.         are provided to manipulate these fields. */
  84.     struct {
  85.         void            *data;        /* pointer to application defined data */
  86.         Boolean        draw:1;        /* false disables drawing and calculating */
  87.         Boolean        visible:1;    /* true means popup is visible */
  88.         Boolean        enabled:1;    /* true if menu is enabled */
  89.         Boolean        typein:1;    /* true shows only arrow, like a type-in menu */
  90.         Boolean        wfont:1;        /* true uses window font, not system font */
  91.         Boolean        fixedwidth:1;/* true uses fixed width for menu */
  92.         char            mark;            /* character used to mark current item */
  93.         char            just;            /* text justification */
  94.         struct {
  95.             Style        style;        /* style of popup's title */
  96.             short        width;        /* width of title; 0 if resized dynamically */
  97.             Handle    str;            /* popup's title string */
  98.         } title;
  99.     } attr;
  100. } PopupType, *PopupPtr, **PopupHandle;
  101.  
  102. Boolean PopupValid(PopupHandle popup);
  103.  
  104. void PopupCalculate(PopupHandle popup);
  105. void PopupDraw(PopupHandle popup);
  106. void PopupHilite(PopupHandle popup);
  107. void PopupSelect(PopupHandle popup);
  108. Boolean PopupWithin(PopupHandle popup, Point pt);
  109.  
  110. short PopupVersion(PopupHandle popup);
  111. short PopupCurrent(PopupHandle popup);
  112. void PopupCurrentSet(PopupHandle popup, short current);
  113. void PopupDrawSet(PopupHandle popup, Boolean draw);
  114. void PopupVisibleSet(PopupHandle popup, Boolean visible);
  115. void PopupMarkSet(PopupHandle popup, char mark);
  116. void PopupEnableSet(PopupHandle popup, Boolean enabled);
  117. void PopupTypeInSet(PopupHandle popup, Boolean typein);
  118. void PopupBounds(PopupHandle popup, Rect *bounds);
  119. void PopupBoundsSet(PopupHandle popup, const Rect *bounds);
  120. void PopupTitle(PopupHandle popup, Str255 title);
  121. void PopupTitleSet(PopupHandle popup, const Str255 title);
  122. void PopupTitleWidthSet(PopupHandle popup, short width);
  123. void PopupTitleStyleSet(PopupHandle popup, Style style);
  124. void PopupUseWFontSet(PopupHandle popup, Boolean wfont);
  125. void PopupFixedWidthSet(PopupHandle popup, Boolean fixedwidth);
  126. void PopupJustSet(PopupHandle popup, short just);
  127.  
  128. PopupHandle PopupBegin(GrafPtr port, MenuHandle menu, const Rect *bounds);
  129. void PopupEnd(PopupHandle popup);
  130.  
  131. pascal long PopupCDEF(short var, ControlHandle ctl, short msg, long param);
  132. void PopupCDEFAttach(ControlHandle ctl);
  133. void PopupCDEFDetach(ControlHandle ctl);
  134.